package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/api/v1/user")
public class WemediaController {
    @Autowired
    WmUserService wmUserService;

    /**
     *      根据名字查自媒体人是否存在
     * @param name
     * @return
     */
    @GetMapping("/findByName/{name}")
    public ResponseResult findByName(@PathVariable("name")String name){

        return wmUserService.findUserByName(name);
    }

    /**
     *      保存自媒体人
     * @param wmUser
     * @return
     */
    @PostMapping("save")
    public ResponseResult save(@RequestBody WmUser wmUser){
        wmUserService.save(wmUser);
        return ResponseResult.okResult(wmUser);
    }



}
